/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author PaolaRestrepo
 */
@Entity
@Table(name = "creditos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Creditos.findAll", query = "SELECT c FROM Creditos c"),
    @NamedQuery(name = "Creditos.findByIdCredito", query = "SELECT c FROM Creditos c WHERE c.idCredito = :idCredito"),
    @NamedQuery(name = "Creditos.findByFechaSolicitud", query = "SELECT c FROM Creditos c WHERE c.fechaSolicitud = :fechaSolicitud"),
    @NamedQuery(name = "Creditos.findByValorCuota", query = "SELECT c FROM Creditos c WHERE c.valorCuota = :valorCuota"),
    @NamedQuery(name = "Creditos.findByPlazos", query = "SELECT c FROM Creditos c WHERE c.plazos = :plazos"),
    @NamedQuery(name = "Creditos.findByTotalCredito", query = "SELECT c FROM Creditos c WHERE c.totalCredito = :totalCredito"),
    @NamedQuery(name = "Creditos.findByEstado", query = "SELECT c FROM Creditos c WHERE c.estado = :estado")})
public class Creditos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idCredito")
    private Integer idCredito;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fechaSolicitud")
    @Temporal(TemporalType.DATE)
    private Date fechaSolicitud;
    @Basic(optional = false)
    @NotNull
    @Column(name = "valorCuota")
    private long valorCuota;
    @Basic(optional = false)
    @NotNull
    @Column(name = "plazos")
    private int plazos;
    @Basic(optional = false)
    @NotNull
    @Column(name = "totalCredito")
    private int totalCredito;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "estado")
    private String estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idCredito")
    private Collection<Pagos> pagosCollection;
    @JoinColumn(name = "idEmpleadoCodeudor", referencedColumnName = "idUsuario")
    @ManyToOne(optional = false)
    private Usuarios idEmpleadoCodeudor;
    @JoinColumn(name = "idEmpleadoAdministrador", referencedColumnName = "idUsuario")
    @ManyToOne(optional = false)
    private Usuarios idEmpleadoAdministrador;
    @JoinColumn(name = "idTipoCredito", referencedColumnName = "idTipo")
    @ManyToOne(optional = false)
    private Tipocredito idTipoCredito;
    @JoinColumn(name = "idEmpleadoTitular", referencedColumnName = "idUsuario")
    @ManyToOne(optional = false)
    private Usuarios idEmpleadoTitular;

    public Creditos() {
    }

    public Creditos(Integer idCredito) {
        this.idCredito = idCredito;
    }

    public Creditos(Integer idCredito, Date fechaSolicitud, long valorCuota, int plazos, int totalCredito, String estado) {
        this.idCredito = idCredito;
        this.fechaSolicitud = fechaSolicitud;
        this.valorCuota = valorCuota;
        this.plazos = plazos;
        this.totalCredito = totalCredito;
        this.estado = estado;
    }

    public Integer getIdCredito() {
        return idCredito;
    }

    public void setIdCredito(Integer idCredito) {
        this.idCredito = idCredito;
    }

    public Date getFechaSolicitud() {
        return fechaSolicitud;
    }

    public void setFechaSolicitud(Date fechaSolicitud) {
        this.fechaSolicitud = fechaSolicitud;
    }

    public long getValorCuota() {
        return valorCuota;
    }

    public void setValorCuota(long valorCuota) {
        this.valorCuota = valorCuota;
    }

    public int getPlazos() {
        return plazos;
    }

    public void setPlazos(int plazos) {
        this.plazos = plazos;
    }

    public int getTotalCredito() {
        return totalCredito;
    }

    public void setTotalCredito(int totalCredito) {
        this.totalCredito = totalCredito;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<Pagos> getPagosCollection() {
        return pagosCollection;
    }

    public void setPagosCollection(Collection<Pagos> pagosCollection) {
        this.pagosCollection = pagosCollection;
    }

    public Usuarios getIdEmpleadoCodeudor() {
        return idEmpleadoCodeudor;
    }

    public void setIdEmpleadoCodeudor(Usuarios idEmpleadoCodeudor) {
        this.idEmpleadoCodeudor = idEmpleadoCodeudor;
    }

    public Usuarios getIdEmpleadoAdministrador() {
        return idEmpleadoAdministrador;
    }

    public void setIdEmpleadoAdministrador(Usuarios idEmpleadoAdministrador) {
        this.idEmpleadoAdministrador = idEmpleadoAdministrador;
    }

    public Tipocredito getIdTipoCredito() {
        return idTipoCredito;
    }

    public void setIdTipoCredito(Tipocredito idTipoCredito) {
        this.idTipoCredito = idTipoCredito;
    }

    public Usuarios getIdEmpleadoTitular() {
        return idEmpleadoTitular;
    }

    public void setIdEmpleadoTitular(Usuarios idEmpleadoTitular) {
        this.idEmpleadoTitular = idEmpleadoTitular;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCredito != null ? idCredito.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Creditos)) {
            return false;
        }
        Creditos other = (Creditos) object;
        if ((this.idCredito == null && other.idCredito != null) || (this.idCredito != null && !this.idCredito.equals(other.idCredito))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.Creditos[ idCredito=" + idCredito + " ]";
    }
    
}
